<?php

namespace app\admin\model;

use think\Model;


class Linestation extends Model
{

    

    

    // 表名
    protected $name = 'line_station';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'is_shang_text',
        'is_jie_text',
        'is_xia_text',
        'is_song_text',
        'map_type_text'
    ];
    

    protected static function init()
    {
        self::afterInsert(function ($row) {
            $pk = $row->getPk();
            $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
        });
    }

    
    public function getIsShangList()
    {
        return ['0' => __('Is_shang 0'), '1' => __('Is_shang 1')];
    }

    public function getIsJieList()
    {
        return ['0' => __('Is_jie 0'), '1' => __('Is_jie 1')];
    }

    public function getIsXiaList()
    {
        return ['0' => __('Is_xia 0'), '1' => __('Is_xia 1')];
    }

    public function getIsSongList()
    {
        return ['0' => __('Is_song 0'), '1' => __('Is_song 1')];
    }

    public function getMapTypeList()
    {
        return ['1' => __('Map_type 1'), '2' => __('Map_type 2')];
    }


    public function getIsShangTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_shang']) ? $data['is_shang'] : '');
        $list = $this->getIsShangList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsJieTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_jie']) ? $data['is_jie'] : '');
        $list = $this->getIsJieList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsXiaTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_xia']) ? $data['is_xia'] : '');
        $list = $this->getIsXiaList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsSongTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_song']) ? $data['is_song'] : '');
        $list = $this->getIsSongList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getMapTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['map_type']) ? $data['map_type'] : '');
        $list = $this->getMapTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
